package com.studyroom.controller;

import com.studyroom.common.Result;
import com.studyroom.dto.ChartDataDTO;
import com.studyroom.dto.StatisticsDTO;
import com.studyroom.entity.Order;
import com.studyroom.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/statistics")
public class StatisticsController {

    @Autowired
    private StatisticsService statisticsService;

    @GetMapping("")
    public Result<StatisticsDTO> getStatistics() {
        return Result.success(statisticsService.getStatistics());
    }

    @GetMapping("/latest-reservations")
    public Result<List<Map<String, Object>>> getLatestReservations() {
        return Result.success(statisticsService.getLatestReservations());
    }

    @GetMapping("/latest-orders")
    public Result<List<Order>> getLatestOrders() {
        return Result.success(statisticsService.getLatestOrders());
    }

    @GetMapping("/reservation-chart")
    public Result<ChartDataDTO> getReservationStatistics() {
        return Result.success(statisticsService.getReservationStatistics());
    }

    @GetMapping("/income-chart")
    public Result<ChartDataDTO> getIncomeStatistics() {
        return Result.success(statisticsService.getIncomeStatistics());
    }
} 